import "./StarScore.scss"

import React from "react"

class StarScore extends React.Component {
    constructor(props) {
        super(props)
    }


    renderStar() {
        let wm_poi_score = this.props.score || '';
        let score = wm_poi_score.toString();

        let scoreArray = score.split('.');
        let fullStar = parseInt(scoreArray[0]);
        let halfStar = parseInt(scoreArray[1]) > 5 ? 1 : 0;
        let nullStar = 5 - fullStar - halfStar
        let array = []
        for (let i = 0; i < fullStar; i++) {
            array.push(<div className="star-item fullStar" key={"fullStar" + i}></div>)
        }
        if (halfStar > 0) {
            array.push(<div className="star-item halfStar" key={"halfStar"}></div>)
        }
        for (let j = 0; j < nullStar; j++) {
            array.push(<div className="star-item nullStar" key={"nullStar" + j}></div>)
        }

        return array
    }
    render() {
        return (
            <div className="StarContent">
                {/* <div className="star-item"></div>
                <div className="star-item"></div>
                <div className="star-item"></div>
                <div className="star-item"></div>
                <div className="star-item"></div> */}
                {this.renderStar()}
            </div>
        )
    }
}
export default StarScore